package com.ai.aiagent.controller;

import com.ai.aiagent.app.LoveApp;
import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatOptions;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * 使用spring ai alibaba 1.0.0.2
 */
@RestController
@RequestMapping("/chatmemory")
public class ChatMemoryController {

    @Resource
    private LoveApp loveApp;

    /**
     * ChatClient 简单调用, 目前千问plus只支持流式调用，该方法调用是失败的
     */
    @GetMapping("/simple/chat")
    public String simpleChat(@RequestParam(value = "message", defaultValue = "你好，很高兴认识你，能简单介绍一下自己吗？")String message,
                             @RequestParam(value = "chatId", defaultValue = "1")String chatId,
                             @RequestParam(value = "userType", defaultValue = "admin")String userType) {
        return loveApp.doChat(message, chatId, userType);
    }
}